package servlet;

import bean.Banji;
import service.BanjiService;
import service.BanjiServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "BanjiQueryServlet" ,urlPatterns = "/banjiQueryServlet")
public class BanjiQueryServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //通过service层获取所有班级信息
        BanjiService banjiService = new BanjiServiceImpl ();
        List<Banji> list = banjiService.BanjiShowService ();
        // 将获取到的所有学员信息放到内置对象，通过客户端跳转的方式显示出来
        request.getSession ().setAttribute ("list",list);
        response.sendRedirect ("Banji.jsp");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost (request,response);
    }
}
